<template>
  <div>
    <el-breadcrumb separator-class="el-icon-arrow-right">
      <el-breadcrumb-item>首页</el-breadcrumb-item>
      <el-breadcrumb-item>提币审核</el-breadcrumb-item>
    </el-breadcrumb>
    <el-card class="box-card">
      <!-- 头部搜索 -->
      <el-row :gutter="10">
        <el-col :span="5">
          <div class="grid-content bg-purple">
            <el-form label-width="80px">
              <el-form-item label="邮箱：">
                <el-input
                  v-model="queryinfo.userEmail"
                  clearable
                  placeholder="请输入邮箱"
                  @clear="getmsgList"
                ></el-input>
              </el-form-item>
            </el-form>
          </div>
        </el-col>
        <el-col :span="5">
          <div class="grid-content bg-purple">
            <el-form label-width="80px">
              <el-form-item label="手机号：">
                <el-input
                  v-model="queryinfo.userTel"
                  clearable
                  placeholder="请输入手机号"
                  @clear="getmsgList"
                ></el-input>
              </el-form-item>
            </el-form>
          </div>
        </el-col>
        <el-button type="primary" icon="el-icon-search" @click="getmsgList"
          >搜索</el-button
        >
      </el-row>
      <!-- 审核数据列表 -->
      <template>
        <el-table :data="tableData" border style="width: 100%">
          <el-table-column label="#" type="index"> </el-table-column>
          <el-table-column prop="id" label="ID" width="80"> </el-table-column>
          <el-table-column prop="nick_name" label="用户昵称"> </el-table-column>
          <el-table-column prop="user_tel" label="手机号"> </el-table-column>
          <el-table-column prop="user_email" label="邮箱"> </el-table-column>
          <el-table-column prop="token_s_en" label="币种"> </el-table-column>
          <el-table-column prop="number" label="数量"> </el-table-column>
          <el-table-column prop="createTime" label="申请时间">
          </el-table-column>
          <el-table-column prop="tohash" label="目标地址"> </el-table-column>
          <el-table-column label="操作">
            <template slot-scope="scope">
              <el-button
                type="success"
                size="mini"
                @click="PassSH(scope.row.id)"
                >通过</el-button
              >
              <el-button
                type="danger"
                size="mini"
                @click="RefuseSH(scope.row.id)"
                >拒绝</el-button
              >
            </template>
          </el-table-column>
        </el-table>
      </template>
      <el-pagination
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
        :page-sizes="[10, 20, 30]"
        :page-size="queryinfo.pageSize"
        layout="total, sizes, prev, pager, next, jumper"
        :total="total"
      >
      </el-pagination>
    </el-card>
  </div>
</template>
<script>
export default {
  data() {
    return {
      queryinfo: {
        userTel: "",
        userEmail: "",
        pageIndex: 1,
        pageSize: 10,
        type: "2",
        status: "2",
        sdate: "",
        edate: "",
      },
      total:0,
      tableData: [],
    };
  },
  created() {
    this.getmsgList();
  },
  methods: {
    // 获取审核列表
    async getmsgList() {
      const { data: res } = await this.$http.post(
        "currencyAudit/currencyAuditFindAll",
        this.httputil(this.queryinfo)
      );
      if (res.code !== 200) return this.$message.error(res.msg);
      this.tableData = res.data.b360FillingUpRecords;
      this.total =res.data.count
    },
    // 通过审核
    async PassSH(id) {
      const data = {
        id: id,
        status: "1",
      };
      const confirmResult = await this.$confirm(
        "此操作将通过审核, 是否继续?",
        "提示",
        {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning",
        }
      ).catch((err) => err);
      if (confirmResult !== "confirm") {
        return this.$message.info("已取消");
      }
      const { data: res } = await this.$http.post(
        "currencyAudit/currencyAuditUpdate",
        this.httputil(data)
      );
      if (res.code !== 200) return this.$message.error(res.msg);
      this.$message.success(res.msg);
      this.getmsgList();
    },
    // 拒绝审核
    async RefuseSH(id) {
      const data = {
        id: id,
        status: "3",
      };
      const confirmResult = await this.$confirm(
        "此操作将拒绝审核, 是否继续?",
        "提示",
        {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning",
        }
      ).catch((err) => err);
      if (confirmResult !== "confirm") {
        return this.$message.info("已取消");
      }
      const { data: res } = await this.$http.post(
        "currencyAudit/currencyAuditUpdate",
        this.httputil(data)
      );
      if (res.code !== 200) return this.$message.error(res.msg);
      this.$message.success(res.msg);
      this.getmsgList();
    },
    // 页面数量发生改变
    handleSizeChange(newSize) {
      this.queryinfo.pageSize = newSize;
      this.getmsgList();
    },
    // 页数发生改变
    handleCurrentChange(newCurrent) {
      this.queryinfo.pageIndex = newCurrent;
      this.getmsgList();
    },
  },
};
</script>
